//
//  VideoPlayerTableViewCell.m
//  LuckyRadio
//
//  Created by JiaRui on 15/11/24.
//  Copyright © 2015年 chenjun. All rights reserved.
//

#import "VideoPlayerTableViewCell.h"
#define kw self.frame.size.width
#define kh self.frame.size.height

@implementation VideoPlayerTableViewCell
-(void)dealloc
{
    [_mvView release];
    [_singerLabel release];
    [_countLabel release];
    [_playView release];
    [_nameLabel release];
    [_hotLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.nameLabel = [[UILabel alloc]init];
        self.singerLabel = [[UILabel alloc]init];
        self.countLabel= [[UILabel alloc]init];
        self.hotLabel = [[UILabel alloc]init];
        self.mvView = [[UIImageView alloc]init];
        self.playView = [[UIImageView alloc]init];
        
        
        [self.mvView addSubview:self.playView];
        [self.contentView addSubview:self.mvView];
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.singerLabel];
        [self.contentView addSubview:self.countLabel];
        [self.contentView addSubview:self.hotLabel];

        [_mvView release];
        [_singerLabel release];
        [_countLabel release];
        [_playView release];
        [_nameLabel release];
        [_hotLabel release];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.nameLabel.frame = CGRectMake( (kw - 20) / 2 + 10, 5, (kw - 30) / 2, (kh - 10) / 3);
    self.singerLabel.frame = CGRectMake( (kw - 20) / 2 + 10, 5 + self.nameLabel.frame.size.height, (kw - 20) / 2, (kh - 10) / 3);
    self.countLabel.frame = CGRectMake( (kw - 20) / 2 + 10, 5 + self.singerLabel.frame.origin.y + self.singerLabel.frame.size.height, (kw - 30) / 2 / 2, (kh - 10) / 3);
    self.hotLabel.frame = CGRectMake( (kw - 20) / 2 + 10 + self.countLabel.frame.size.width, 5 + self.singerLabel.frame.origin.y + self.singerLabel.frame.size.height, (kw - 30) / 2 / 2, (kh - 10) / 3);

    self.mvView.frame = CGRectMake( 10, 5, (kw - 20) / 2, kh - 10);
    self.playView.frame = CGRectMake( self.mvView.frame.size.width / 2 - 20, self.mvView.frame.size.height / 2 - 20, 40, 40);

}
- (void)setModel:(MVClassModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.nameLabel.text = model.videoName;
    self.nameLabel.font = [UIFont systemFontOfSize:17];
    self.singerLabel.text = model.singerName;
    self.singerLabel.font = [UIFont systemFontOfSize:13];
    self.countLabel.text = [NSString stringWithFormat:@"◀️%@", model.pickCount];
    self.hotLabel.text = [NSString stringWithFormat:@"💗%@", model.bulletCount];
    [self.mvView sd_setImageWithURL:[NSURL URLWithString:[model.mvList[0] picUrl]] placeholderImage:[UIImage imageNamed:@"Read_zhanwei"]];
    
}
+ (VideoPlayerTableViewCell *)VideoPlayerTableViewCellWithTableView:(UITableView *)tableView
{
    static NSString * cellIden = @"cellIden";
    VideoPlayerTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIden];
    if (!cell) {
        cell = [[VideoPlayerTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIden];
    }
    return cell;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
